package com.zzg.datastructure.search;

/**
 * @Author zhengzg
 * @Date 2022-09-15
 * @Version v1.0
 * 线性查找法
 */
public class SeqSearch {
    public static void main(String[] args) {
        int[] arr = {1, 9, 11, -1, 89};

        int index = seqSearch(arr,-11);

        if (index == -1) {
            System.out.println("没有找到");
        } else {
            System.out.println("找到，下标为=" + index);
        }
    }

    private static int seqSearch(int[] arr, int value) {
        for (int item : arr) {
            if (item == value) {
                return value;
            }
        }
        return -1;
    }
}
